#ifndef TETRISEXCEPTION_H
#define TETRISEXCEPTION_H

/*!
 * \file     tetrisexception.h
 * \brief    Exceptions of Tetris.
 * \author   Duriez Franck
 * \author   Carton Paul-Henri
 * \version  0.1
 */

#include <exception>
#include <string>

/*!
 * \namespace TetrisException
 * \brief     All Exceptions directly related with Tetris : Square, Shape, Grid...
 */
namespace TetrisException /*{{{*/
{
	/*!
	 * \class UnexpectedShape
	 * \brief This happen when a Shape pointer is not NULL but expected NULL.
	 */
	class UnexpectedShape : std::exception /*{{{*/
	{
	public:
		UnexpectedShape(std::string what) throw() : /*{{{*/
		m_what(what)
		{
		} /*}}}*/

		virtual ~UnexpectedShape() throw() /*{{{*/
		{
		} /*}}}*/

		const char* what() const throw() /*{{{*/
		{
			return m_what.data();
		} /*}}}*/

	private:
		std::string m_what;
	}; /*}}}*/

	/*!
	 * \class ShapeOwnershipConflict
	 * \brief This happen when a Shape is already assigned to a Grid.
	 */
	class ShapeOwnershipConflict : std::exception /*{{{*/
	{
	public:
		ShapeOwnershipConflict(std::string what) throw() : /*{{{*/
		m_what(what)
		{
		} /*}}}*/

		virtual ~ShapeOwnershipConflict() throw() /*{{{*/
		{
		} /*}}}*/

		const char* what() const throw() /*{{{*/
		{
			return m_what.data();
		} /*}}}*/

	private:
		std::string m_what;
	}; /*}}}*/

	/*!
	 * \class ExpectedShape
	 * \brief This happen when a Shape pointer is NULL but expected not.
	 */
	class ExpectedShape : std::exception /*{{{*/
	{
	public:
		ExpectedShape(std::string what) throw() : /*{{{*/
		m_what(what)
		{
		} /*}}}*/

		virtual ~ExpectedShape() throw() /*{{{*/
		{
		} /*}}}*/

		const char* what() const throw() /*{{{*/
		{
			return m_what.data();
		} /*}}}*/

	private:
		std::string m_what;
	}; /*}}}*/
	
	/*!
	 * \class ExpectedSquare
	 * \brief This happen when a pointer in Container::m_objects is NULL but expected not.
	 */
	class ExpectedSquare : std::exception /*{{{*/
	{
	public:
		ExpectedSquare(std::string what) throw() : /*{{{*/
		m_what(what)
		{
		} /*}}}*/

		virtual ~ExpectedSquare() throw() /*{{{*/
		{
		} /*}}}*/

		const char* what() const throw() /*{{{*/
		{
			return m_what.data();
		} /*}}}*/

	private:
		std::string m_what;
	}; /*}}}*/

	/*!
	 * \class UnexpectedSquare
	 * \brief This happen when a pointer in Container::m_objects is not NULL but expected NULL.
	 */
	class UnexpectedSquare : std::exception /*{{{*/
	{
	public:
		UnexpectedSquare(std::string what) throw() : /*{{{*/
		m_what(what)
		{
		} /*}}}*/

		virtual ~UnexpectedSquare() throw() /*{{{*/
		{
		} /*}}}*/

		const char* what() const throw() /*{{{*/
		{
			return m_what.data();
		} /*}}}*/

	private:
		std::string m_what;
	}; /*}}}*/
} /*}}}*/

#endif // TETRISEXCEPTION_H
